import request from '@/utils/request'
import Cookies from "js-cookie";
import { getToken } from "@/utils/auth";
var axios = require('axios');






// 登录方法
export function login(username, password, captcha, checkKey) {
  var data = JSON.stringify({
    "account": username,
    "password": password
  });
  var config = {
    method: 'post',
    url: '/login',
    headers: {
      'Content-Type': 'application/json',
      'Cookie': 'Authorization=eyJhbGciOiJIUzUxMiJ9.eyJ1c2VySWQiOjEzMzk1NTA0Njc5Mzk2MzkyOTksImFjY291bnQiOiJhZG1pbiIsInV1aWQiOiJmOTkyYjA3Mi1kN2Q5LTQzN2YtYmRmNC1iYzk1OTAwN2RiMmMiLCJyZW1lbWJlck1lIjpmYWxzZSwiZXhwaXJhdGlvbkRhdGUiOjE2NjE4NTg1NTk3MTIsImNhVG9rZW4iOm51bGwsIm90aGVycyI6bnVsbCwic3ViIjoiMTMzOTU1MDQ2NzkzOTYzOTI5OSIsImlhdCI6MTY2MTI1Mzc1OSwiZXhwIjoxNjYxODU4NTU5fQ.3-onbxXpeXZkjBHTOIsRM5UOIm0Rh5UXLgIT_FgvsUmJUJhuvgC2d12o1eJ8n93_KvGkoly785VIZC1PrUrA9g'
    },
    data : data
  };
  return axios(config)
  // return request({
  //   url: '/login',
  //   headers: {
  //     isToken: false
  //   },
  //   method: 'post',
  //   data:data
  // })
}

// 注册方法
export function register(data) {
  return request({
    url: '/register',
    headers: {
      isToken: false
    },
    method: 'post',
    data: data
  })
}

// 获取用户详细信息
export function getAgrProjects(query) {
  debugger
  debugger
  return request({
    url: `/jeecg-boot/agr/agrProjects/list4cus`,
    method: 'get',
    headers:{
      isToken:true,
      'X-Access-Token':getToken()
    },
    params: query
  })
  // return request({
  //   url: '/jeecg-boot/agr/agrProjects/list',
  //   method: 'get',
  //   headers:{
  //    isToken:true,
  //    'X-Access-Token':getToken()
  //   }
  // })
}

//项目列表
export function getAgrProjectList() {
  debugger
  return request({
    url: '/jeecg-boot/agr/agrProjects/list4cus',
    method: 'get',
    headers:{
     isToken:true,
     'X-Access-Token':getToken()
    }
  })
}




// 退出方法
export function logout() {
  return request({
    url: '/logout',
    method: 'post'
  })
}

// 获取验证码
export function getCodeImg() {
  return request({
    url: '/captchaImage',
    headers: {
      isToken: false
    },
    method: 'get',
    timeout: 20000
  })
}
